﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using HighLowTriple7;
using HighLowTriple7.Entity;
using Utils;

public partial class userControls_ucGame : System.Web.UI.UserControl
{
    public BetGameResult OldSession = new BetGameResult();
    public int AccountId
    {
        set { ViewState["AccountId"] = value; }
        get
        {
            try
            {
                return (Int32)ViewState["AccountId"];
            }
            catch
            {
                return -1;
            }
        }
    }
    public int Au
    {
        set { ViewState["Money_Au"] = value; }
        get
        {
            try
            {
                return (Int32)ViewState["Money_Au"];
            }
            catch
            {
                return -1;
            }
        }
    }
    public int Ag
    {
        set { ViewState["Money_Ag"] = value; }
        get
        {
            try
            {
                return (Int32)ViewState["Money_Ag"];
            }
            catch
            {
                return -1;
            }
        }
    }
    public int TypeAccount
    {
        set { ViewState["TypeAccount"] = value; }
        get
        {
            try
            {
                return (Int32)ViewState["TypeAccount"];
            }
            catch
            {
                return -1;
            }
        }
    }
    public string UserName
    {
        set { ViewState["UserName"] = value; }
        get
        {
            try
            {
                return (string)ViewState["UserName"];
            }
            catch
            {
                return string.Empty;
            }
        }
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        var ran = new Random();
        if (UserUtils.IsLogin)
        {
            try
            {
                if ((UserUtils.Triple7AccessToken ?? "") == "")
                    UserUtils.Triple7AccessToken = Triple7.Instance(AccountId, UserName, TypeAccount);
                string accessToken = UserUtils.Triple7AccessToken;
                if (Triple7.GetGameStatus(accessToken) == 5)
                {

                    OldSession.Val1 = Triple7.GetColumn1Value(accessToken);
                    OldSession.Val2 = Triple7.GetColumn2Value(accessToken);
                    OldSession.Val3 = Triple7.GetColumn3Value(accessToken);
                    OldSession.Au = Triple7.GetAuCurrent(accessToken);
                    OldSession.Ag = Triple7.GetAgCurrent(accessToken);
                    OldSession.Result = Triple7.GetGameStatus(accessToken);
                    OldSession.RateConfig = Triple7.GetRateConfig(OldSession.Au > 0 ? OldSession.Au : OldSession.Ag, accessToken);
                }
                else
                {
                    OldSession.Val1 = ran.Next(1, 14);
                    OldSession.Val2 = ran.Next(1, 14);
                    OldSession.Val3 = ran.Next(1, 14);
                    OldSession.Au = 0;
                    OldSession.Ag = 0;
                    OldSession.Result = 4;
                    OldSession.RateConfig = new RateConfigEntity();
                }
            }
            catch
            {

            }
        }
        else
        {
            OldSession.Val1 = ran.Next(1, 14);
            OldSession.Val2 = ran.Next(1, 14);
            OldSession.Val3 = ran.Next(1, 14);
            OldSession.Au = 0;
            OldSession.Ag = 0;
            OldSession.Result = 4;
            OldSession.RateConfig = new RateConfigEntity();
        }
    }
}